rm(list=ls())
 setwd("/Files for R/ReSTAT")
library("Matrix")
library('foreign')
library('ggplot2')
library('lubridate')

#### Run Code for Residential Facilities

# First build the matrix of peer overlap days
source("Peer Matrix Code_ReSTAT.R")

# Build peer variables (not interacted with distance)
source("Peer Weights_ReSTAT.R")

# Build peer distance (distance between home zip codes) matrix
source("Distance Matrix_ReSTAT.R")

# Build peer distance variables (peer CH for neighboring peers, etc.)
source("Peer Weights Distance_ReSTAT.R")

#### Run Code for Day Treatment Facilities

# First build the matrix of peer overlap days
source("Peer Matrix Code Day_ReSTAT.R")

# Build peer variables (not interacted with distance)
source("Peer Weights Day_ReSTAT.R")

#### Run code for permutation test
source("permutation_test_SHORT_ReSTAT.R")


#### Run code for split sample test
source("Cluster Split Sample ReSTAT.R")
source("Cluster Split Sample Day ReSTAT.R")
